﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrderEdit.aspx.cs" Inherits="CNVP.JShop.Web.Admin.OrderEdit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
            <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="IE=7" http-equiv="X-UA-Compatible" />
    <style type="text/css">
    .divProductTip
    {  
        width:100px;
        height:50px;
        position:absolute;
	    z-index:100;
	    
	    background-color:#CCCCCC;
    }
    </style>
    <link href="CSS/Edit.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery.js" type="text/javascript"></script>
    <script src="../Scripts/Common.js" type="text/javascript"></script>
    <script src="JS/Calendar.js" type="text/javascript"></script>
    <script type="text/javascript">
     //选择省份时引发的动作
        function ProvinceChange() {
            var ddlProvince = document.getElementById("<%=ddlProvince.ClientID %>");
            var selectCity = document.getElementById("selectCity");
            selectCity.innerHTML = GetAjaxResponse("CommonWindows/AjaxCity.aspx?Type=ProvinceID&Code=" + ddlProvince.value);
            if(ddlProvince.value==<%=Province %>)
            {
                var ListCity = document.getElementById("ListCity");
                ListCity.value=<%=City %>;
            }
            CityChange();
            
        }
        //选择市时引发的动作
        function CityChange() {
            var ListCity = document.getElementById("ListCity");
            var selectArea = document.getElementById("selectArea");
            selectArea.innerHTML = GetAjaxResponse("CommonWindows/AjaxCity.aspx?Type=CityID&Code=" + ListCity.value);
            if(ListCity.value==<%=City %>)
            {
                var ListArea = document.getElementById("ListArea");
                ListArea.value=<%=Area %>;
            }
        }
    </script>
    <script type="text/javascript">
        $(function () {
            $(".inputProductNum").bind("click", function () {
                var div = "<div class=\"divProductTip\"> 库存量:</div>";
                $("#lbOrderProducts").append(div);
                $(".divProductTip").css({ "top": $(this).offset().top + 20, "left": $(this).offset().left });
                var productDetailID = $(this).attr("productDetailID");
                $.post("ProductStockTotal.ashx", { "productDetailID": productDetailID }, function (data, st) {
                    if (st == "success") {
                        //alert(data);
                        $(".divProductTip").append("   " + data);
                    }
                });
            });
            $(".inputProductNum").bind("blur", function () {
                if ($(".divProductTip")) {
                    $(".divProductTip").remove();
                }
            });
        });
    </script>
</head>
<body onload="ProvinceChange();">
    <form id="form1" runat="server" autocomplete="off">
        <div class="Content">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="cell">
             <tr>
                <td class="cell_group">
                    <img src="Images/ListIconTitle.jpg" alt="" />&nbsp;您的位置：<a href="OrderList.aspx">订单管理</a> > 修改
                    
                </td>
            </tr>
            </table>
            <h3>商品信息</h3>
            <div class="division">
                <input type="text" id="txtindexNum" runat="server" class="Display" />
                <asp:Label ID="lbOrderProducts" runat="server"></asp:Label>
                <script type ="text/javascript">
                    function OrderProductsOnchang(index, IDS) {
                        
                        var Allprice = 0.00;
                        var Num = document.getElementById("Num" + index + "").value;
                        var NumCompare = document.getElementById("NumCompare" + index + "").value;
                        var Price = document.getElementById("Price" + index + "").value;
                        var spantotalPrice = document.getElementById("spantotalPrice" + index + "");
                        var totalPrice = document.getElementById("totalPrice" + index + "");
                        var CompareValue = parseInt(Num) - parseInt(NumCompare);
                        if (Num < 0) {
                            document.getElementById("Num" + index + "").value = document.getElementById("NumCompare" + index + "").value;
                            Allprice = parseFloat(Price) * parseFloat(NumCompare);
                            spantotalPrice.innerHTML = Allprice;
                            totalPrice.value = Allprice;
                            TotalCount();
                        }
                        else {
                            var NumState = GetAjaxResponse("CommonWindows/AjaxProDetailNum.aspx?IDS=" + IDS + "&CompareValue=" + CompareValue);
                            if (NumState == "0") {
                                alert("库存不足！");
                                document.getElementById("Num" + index + "").value = document.getElementById("NumCompare" + index + "").value;
                                Allprice = parseFloat(Price) * parseFloat(NumCompare);
                                spantotalPrice.innerHTML = Allprice;
                                totalPrice.value = Allprice;
                                TotalCount();
                            }
                            else {
                                Allprice = parseFloat(Price) * parseFloat(Num);
                                spantotalPrice.innerHTML = Allprice;
                                totalPrice.value = Allprice;
                                TotalCount();
                            }
                        }
                    }
                    function Del(index) {
                        var Num = document.getElementsByName("Num");
                        if (Num.length== 1) {
                            alert("无法全部删除,订单中必须有产品！");
                        }
                        else {
                            var indexNum = "";
                            if (confirm("你确定要删除！")) {
                                $("#tr" + index + "").remove();
                                indexNum = index + ",";
                                //alert(indexNum);
                                TotalCount(); //再计算
                            }
                            var txtindexNum = document.getElementById("txtindexNum");
                            txtindexNum.value += indexNum;
                        }
                    }
                    function TotalCount() {
                        var getTotalList = 0.00;
                        var getTotalPrice = document.getElementsByName("totalPrice");
                        for (var i = 0; i < getTotalPrice.length; i++) {
                            //alert(getTotalPrice[i].value);
                            getTotalList += parseFloat(getTotalPrice[i].value);
                        }
                        //alert(getTotalList);
                        var txtProductsTotalAmount = document.getElementById("<%=txtProductsTotalAmount.ClientID %>");
                        txtProductsTotalAmount.value = getTotalList;
                        var txtDeliveryPrice = document.getElementById("<%=txtDeliveryPrice.ClientID %>");
                        var txtPayFactorage = document.getElementById("<%=txtPayFactorage.ClientID %>");
                        var txtSalesPromotionAmount = document.getElementById("<%=txtSalesPromotionAmount.ClientID %>");
                        var txtDiscountOrder = document.getElementById("<%=txtDiscountOrder.ClientID %>");
                        var txtOrderTotalAmount = document.getElementById("<%=txtOrderTotalAmount.ClientID %>");
                        var txtSupportValuePrice = document.getElementById("<%=txtSupportValuePrice.ClientID %>");
                        var cbIsSupportValue = document.getElementById("<%=cbIsSupportValue.ClientID %>");
                        var txtBilTaxes = document.getElementById("<%=txtBilTaxes.ClientID %>");
                        var cbIsNeedBill = document.getElementById("<%=cbIsNeedBill.ClientID %>");
                        var SupportValue = 0.00;
                        var AllPrice = 0.00;
                        if (cbIsSupportValue.checked == true) {
                            AllPrice = parseFloat(txtSupportValuePrice.value);
                        }
                        else {
                            txtSupportValuePrice.value = 0.00;
                        }
                        if (cbIsNeedBill.checked == true) {
                            AllPrice += parseFloat(txtBilTaxes.value);

                        }
                        else {
                            txtBilTaxes.value = 0.00;
                        }
                        txtOrderTotalAmount.value = AllPrice + parseFloat(txtProductsTotalAmount.value) + parseFloat(txtDeliveryPrice.value) + parseFloat(txtPayFactorage.value) - parseFloat(txtSalesPromotionAmount.value) + parseFloat(txtDiscountOrder.value);
                    }
                </script>
                </div>
            <h3>订单信息</h3>
                 <table border="0" cellpadding="0" cellspacing="0"  width="100%" class="division">
                    <tbody >
                        <tr >
                            <th >
                                订&nbsp;单&nbsp;号：</th>
                            <td >
                                <asp:Label ID="lbOrderNum" runat="server"></asp:Label>
                            </td>
                            <th >
                                下单日期：</th>
                            <td >
                                <asp:Label ID="lbAddTime" runat="server"></asp:Label>
                            </td>
                        </tr>
                        <tr >
                            <th >
                                商品总金额：</th>
                            <td >
                                <asp:TextBox ID="txtProductsTotalAmount" runat="server" ReadOnly="True"></asp:TextBox>
                            </td>
                            <th >
                                配送方式：</th>
                            <td >
                                <asp:Label ID="lbDeliveryWay" runat="server"></asp:Label>
                            </td>
                        </tr>
                        <tr >
                            <th >
                                配送费用：</th>
                            <td >
                                <asp:TextBox ID="txtDeliveryPrice" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                            <th >
                                支付方式：</th>
                            <td >
                                <asp:DropDownList ID="ddlPayWay" runat="server" Width="150px">
                                     <asp:ListItem Value="">--请选择--</asp:ListItem>
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr >
                            <th >
                                保&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价：</th>
                            <td >
                                <asp:TextBox ID="txtSupportValuePrice" runat="server" MaxLength="50"></asp:TextBox>
                                <asp:CheckBox ID="cbIsSupportValue" runat="server" Text="是否保价" />
                            </td>
                            <th >
                                商品重量：</th>
                            <td >
                                <asp:TextBox ID="txtProductWeight" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                        </tr>
                        <tr >
                            <th >
                                支付手续费：</th>
                            <td >
                                <asp:TextBox ID="txtPayFactorage" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                            <th >
                                发票抬头：</th>
                            <td >
                                <asp:TextBox ID="txtBillRises" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                        </tr>
                        <tr >
                            <th >
                                税&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;金：</th>
                            <td >
                                <asp:TextBox ID="txtBilTaxes" runat="server" MaxLength="50"></asp:TextBox>
                                <asp:CheckBox ID="cbIsNeedBill" runat="server" Text="是否开发票" />
                            </td>
                            <th >
                                支付币别：</th>
                            <td >
                                人民币
                            </td>
                        </tr>
                        <tr >
                            <th >
                                促销优惠金额：</th>
                            <td >
                                <asp:TextBox ID="txtSalesPromotionAmount" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                            <th >
                                折扣或涨价：</th>
                            <td >
                                <asp:TextBox ID="txtDiscountOrder" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                        </tr>
                        <tr >
                            <th >
                                总&nbsp;金&nbsp;额：</th>
                            <td >
                                <asp:TextBox ID="txtOrderTotalAmount" runat="server" ReadOnly="True"></asp:TextBox>
                            </td>
                        </tr>
                        <tr >
                            <th >
                                补充说明：</th>
                            <td >
                                <asp:TextBox ID="txtText" runat="server" Height="100px" TextMode="MultiLine" 
                                    Width="400px"></asp:TextBox>
                            </td>
                        </tr>
                    </tbody>
                </table>
           <h3>购买人信息</h3>
            <div class="division">
                <asp:Label ID="lbBuyerInfo" runat="server"></asp:Label>
                </div>
           <h3>收货人信息</h3>
                <table border="0" cellpadding="0" cellspacing="0" width="100%" class="division">
                    <tbody >
                        <tr >
                            <th>
                                收货人姓名：</th>
                            <td>
                                <asp:TextBox ID="txtGetTrueName" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                            <th>
                                联系手机：</th>
                            <td>
                                <asp:TextBox ID="txtMobilePhone" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                        </tr>
                        <tr >
                            <th>
                                联系电话：</th>
                            <td>
                                <asp:TextBox ID="txtPhone" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                            <th>
                                Email地址：</th>
                            <td>
                                <asp:TextBox ID="txtEmail" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                        </tr>
                        <tr >
                            <th>
                                送货时间：</th>
                            <td>
                                 <input name="txtPostTime" type="text" id="txtPostTime" onclick="calendar.show(this);" size="18" maxlength="10" readonly="readonly" runat="server" />
                            </td>
                            <th>
                                邮政编码：</th>
                            <td>
                                <asp:TextBox ID="txtZipCode" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                        </tr>
                        <tr >
                            <th>
                                 收货地区：</th>
                            <td colspan="3">
                                <asp:DropDownList ID="ddlProvince" runat="server">
                                <asp:ListItem Value="">--请选择--</asp:ListItem>
                                </asp:DropDownList>
                                <span id="selectCity"></span>
                                <span id="selectArea"></span>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                收货地址：
                              </th>
                            <td colspan="3">
                                <asp:TextBox ID="txtGetAddress" runat="server" Width="350px" MaxLength="50"></asp:TextBox>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div class="EditBtn">     
                    <asp:Button ID="btUp" runat="server" Text="提交" OnClick="btUp_Click" />
                    <input type="button" value="取消" onclick="javascript:history.go(-1)" />
                    </div>
   <script type="text/javascript">
       $(function () {
           $("#btUp").click(function () {
               var $txtDeliveryPrice = $("#txtDeliveryPrice");
               if (!IsDouble($txtDeliveryPrice.val())) {
                   alert("运费格式不正确！");
                   $txtDeliveryPrice.focus();
                   return false;
               }
               var $ddlDeliveryWay = $("#ddlDeliveryWay");
               if ($ddlDeliveryWay.val() == "") {
                   alert("请选择配送方式！");
                   $ddlDeliveryWay.focus();
                   return false;
               }
               var $ddlPayWay = $("#ddlPayWay");
               if ($ddlPayWay.val() == "") {
                   alert("请选择支付方式！");
                   $ddlPayWay.focus();
                   return false;
               }
               var $txtSupportValuePrice = $("#txtSupportValuePrice");
               if (!IsDouble($txtSupportValuePrice.val())) {
                   alert("保价格式不正确！");
                   $txtSupportValuePrice.focus();
                   return false;
               }
               var $txtProductWeight = $("#txtProductWeight");
               if (!IsDouble($txtProductWeight.val())) {
                   alert("商品重量格式不正确！");
                   $txtProductWeight.focus();
                   return false;
               }
               var $txtPayFactorage = $("#txtPayFactorage");
               if (!IsDouble($txtPayFactorage.val())) {
                   alert("支付手续费格式不正确！");
                   $txtPayFactorage.focus();
                   return false;
               }
               var $txtBilTaxes = $("#txtBilTaxes");
               if (!IsDouble($txtBilTaxes.val())) {
                   alert("税金格式不正确！");
                   $txtBilTaxes.focus();
                   return false;
               }
               var $txtSalesPromotionAmount = $("#txtSalesPromotionAmount");
               if (!IsDouble($txtSalesPromotionAmount.val())) {
                   alert("促销优惠金额格式不正确！");
                   $txtSalesPromotionAmount.focus();
                   return false;
               }
               var $txtDiscountOrder = $("#txtDiscountOrder");
               if (!IsDouble($txtDiscountOrder.val())) {
                   alert("折扣或涨价格式不正确！");
                   $txtDiscountOrder.focus();
                   return false;
               }
               var $ddlProvince = $("#ddlProvince");
               if ($ddlProvince.val() == "") {
                   alert("请选择省区！");
                   $ddlProvince.focus();
                   return false;
               }
               var $ListCity = $("#ListCity");
               if ($ListCity.val() == "") {
                   alert("请选择市区！");
                   $ListCity.focus();
                   return false;
               }
               var $ListArea = $("#ListArea");
               if ($ListArea.val() == "") {
                   alert("请选择地区！");
                   $ListArea.focus();
                   return false;
               }
               var $txtGetAddress = $("#txtGetAddress");
               if ($txtGetAddress.val() == "") {
                   alert("请输入收货地址！");
                   $txtGetAddress.focus();
                   return false;
               }
               var $txtTrueName = $("#txtTrueName");
               if ($txtTrueName.val() == "") {
                   alert("请输入收货人姓名！");
                   $txtTrueName.focus();
                   return false;
               }
               var $txtMobilePhone = $("#txtMobilePhone");
               if ($txtMobilePhone.val() == "") {
                   alert("请输入手机号码！");
                   $txtMobilePhone.focus();
                   return false;
               }
               if (!IsValidMobilePhone($txtMobilePhone.val())) {
                   alert("手机号码格式不正确！");
                   $txtMobilePhone.focus();
                   return false;
               }
               var $txtPhone = $("#txtPhone");
               if ($txtPhone.val() != "") {
                   if (!IsValidPhone($txtPhone.val())) {
                       alert("电话号码格式不正确！");
                       $txtPhone.focus();
                       return false;
                   }
               }
           });
       })
   </script>
   </div>
    </form>
</body>
</html>
